package fonkin.com.wifisignapp.adapter.news;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.Collection;
import java.util.List;

import fonkin.com.wifisignapp.R;
import fonkin.com.wifisignapp.bean.news.NewsInfor;
import fonkin.com.wifisignapp.bean.tissue.Department;
import fonkin.com.wifisignapp.constants.AppConstants;

import static com.squareup.picasso.MemoryPolicy.NO_CACHE;
import static com.squareup.picasso.MemoryPolicy.NO_STORE;

/**
 * @Description:部门列表Adapter
 * @Author: huanghongjing
 * @Date: 2018/4/7 23:43
 * No such property: code for class: Script1
 *
 */

public class DeptAdapter extends BaseAdapter {
    private Context context;
    private List<Department> deptsInfoList;

    public DeptAdapter(Context context, List<Department> deptsInfoList) {
        this.context = context;
        this.deptsInfoList = deptsInfoList;
    }

    @Override
    public int getCount() {
        return deptsInfoList.size();
    }

    @Override
    public Object getItem(int position) {
        return deptsInfoList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.dept_item,parent,false);
            convertView.setTag(new Viewholder(convertView));
        }
        Viewholder tag = (Viewholder) convertView.getTag();

       Department deptInfor = deptsInfoList.get(position);
        tag.dept.setText(deptInfor.getDeptName());


        return convertView;
    }

    public void addAll(Collection<? extends Department> collection){
        deptsInfoList.addAll(collection);
        notifyDataSetChanged();
    }
    public static  class Viewholder{

        private final TextView dept;

        public  Viewholder(View item){
            dept = ((TextView) item.findViewById(R.id.dept_name));


        }
    }
}
